package com.example.meitao.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.meitao.R;

/**
 * Created by wudi on 2016/8/29.
 */
public class MyMessage extends LinearLayout{

    private ImageView iv_title,iv_test;
    private TextView tv_test,tv_garbage;

    public MyMessage(Context context, AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(context).inflate(R.layout.view_mymessage,this);
        //获取姓名
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MyMessage);
        int id_title = typedArray.getResourceId(R.styleable.MyMessage_picTitle, 0);
        int id_test = typedArray.getResourceId(R.styleable.MyMessage_picTest, 0);
        String test =typedArray.getString(R.styleable.MyMessage_test);
        String garbage =typedArray.getString(R.styleable.MyMessage_garbage);

        iv_title = (ImageView) view.findViewById(R.id.iv_message_title);
        iv_test = (ImageView) view.findViewById(R.id.iv_message_other);
        tv_test = (TextView) view.findViewById(R.id.tv_message_test);
        tv_garbage = (TextView) view.findViewById(R.id.tv_message_garbage);
        iv_title.setImageResource(id_title);
        iv_test.setImageResource(id_test);
        tv_test.setText(test);
        tv_garbage.setText(garbage);
    }

}
